<!DOCTYPE html>
<html>

<head>
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta charset="utf-8">
  <title></title>
  <meta name="keywords" content="">
  <meta name="description" content="">
  <meta name="author" content="">
  <link href="css/daterangepicker.min.css" rel="stylesheet">
  <link rel="stylesheet" href="css/main.css">

  <script src="js/vue.js"></script>
  <script src="js/request.js"></script>
  <script src="https://unpkg.com/element-ui/lib/index.js"></script>
  <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">


  <!--[if lt IE 9]>
	<script src="js/html5shiv.min.js"></script>
	<script src="js/respond.min.js"></script>
<![endif]-->
  <meta name="renderer" content="webkit">
  <link rel="shortcut icon" href="favicon.ico">
</head>

<body>
  <div id="apps">
    <header></header>
    <div class="header-space"></div>

    <section class="banner-ad">
      <a href="" style="background-image: url(images/banner241.png);"></a>
    </section>

    <section class="section231">
      <div class="content w900">
        <div class="form">
          <select v-model="param.type">
            <option v-for="item in list" :value="item.id">{{item.name}}</option>
          </select>
          <textarea v-model="param.content" cols="30" rows="10" placeholder="描述您的建议（1000 字）"></textarea>
        </div>
        <div class="operate">
          <input type="submit" value="提交" class="btn" @click="goFun">
        </div>
      </div>
    </section>

    <footer>
      <div class="content">
    </footer>
  </div>
  <script src="js/jquery.min.js"></script>
  <script src="js/slide.min.js"></script>
  <script src="js/polyfill.min.js"></script>
  <script src="js/jquery.nicescroll3.7.6.min.js"></script>
  <script src="js/main.js"></script>
  <script>
    $(function() {
      $("header").load("./enterpriseCommon/header.html");
      $("footer").load("./enterpriseCommon/footer.html");
    });
    var vm = new Vue({
      el: '#apps',
      data: function() {
        return {
          list: null,
          param: {
            type: '',
            content: ''
          }
        }
      },
      created: function() {
        this.getList();
      },
      methods: {
        goFun: function() {
          if (!this.param.content) {
            this.$message({
              type: 'error',
              message: '请输入建议'
            })
          }
          var url = 'company/suggestion';
          var self = this;
          request(url, 'PUT', JSON.stringify(this.param), function(res) {
            if (res.code === 1) {
              self.$message({
                type: 'success',
                message: '提交成功'
              })
              self.param.content = '';
              self.param.type = self.list[0].id || '';
            }
          }, function(err) {
            console.log(err)
          })
        },
        getList: function() {
          var url = 'enterprise/company/prepare';
          var self = this;
          request(url, 'GET', '', function(res) {
            console.log('基础信息', res)
            if (res.code === 1) {
              self.list = res.data.suggestion_type;
              self.param.type = res.data.suggestion_type[0].id;
            }
          }, function(err) {
            console.log(err)
          })
        }
      }
    })

  </script>
</body>

</html>
